An SDK is used by the application to access the APIs permitting queries and

updates to the ledger by performing the following steps:

1. Enroll an admin user using the enrollAdmin.js script:

$ sudo node enrollAdmin.js

When we launch the network, an admin user needs to be registered with

the certificate authority, we send an enrollment call to the CA server, and

the enrollment certificate (eCert) for this user is retrieved. To

subsequently register and enroll other users, we use the admin user.

2. Register a user called user1 using the registerUser.js script:

1. sudo node registerUser.js

3 . Let us communicate with the CA server once more to register and enroll

user1 with the newly generated eCert for the admin user. We can use the

ID of user1 to query and update the ledger.

Against the ledger, let us run a query:

sudo node registerUser.js

4. With 10 wagons on the network, from wagon0 to wagon9 each having a

color, doctype, make, model, and the owner it returns on the screen.

5 . U sing the q ueryAllWagons function to query all wagons the chaincode

constructs the query:

queryWagon chaincode function –it requires 1 argument, e.g.,

args: ['Wagon4'],

queryAllWagons chaincode function –it requires no arguments,

e.g., args: [''],

const request = {

chaincodeId: 'wagon',

fcn: 'queryAllWagons',

args: ['']

}

6. We will update the invoke.js script for updating the ledger. To insert a

new wagon, Wagon10 into the ledger, this time, the wagon chaincode

uses the createWagon function:

var request = {

chaincodeId: 'wagon',

fcn: 'createWagon',

args: ['WAGON10', 'Chevy', 'Volt', 'Red', 'Vicky'],

chainId: 'mychannel',